<?php

session_start();
if(!array_key_exists("user", $_SESSION) || $_SESSION['account'] != 2){
	header("Location: ../common/redirect.php");
	exit;
}

include_once("../class/db.php");
$db = new db();

if(array_key_exists("questiontype", $_POST)){
	switch($_POST['questiontype']){
/* --------------------------------------------------------------------------- */
		case "file":
			if (($gestor = fopen($_FILES['csv_file']['tmp_name'], "r")) !== FALSE) {
				$counter = 1;
				$error = array();
				while (($datos = fgetcsv($gestor, 0, ",")) !== FALSE) {
					switch($_POST['question_type']){
						case "optional":
							if(count($datos) == 5){
							$sql = "INSERT INTO questions (uid, owner, question_type, question, answer, falsea, falseb, falsec) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", {$_SESSION['user']}, '{$_POST['question_type']}', '".htmlspecialchars($datos[0], ENT_QUOTES)."', '".htmlspecialchars($datos[1], ENT_QUOTES)."', '".htmlspecialchars($datos[2], ENT_QUOTES)."', '".htmlspecialchars($datos[3], ENT_QUOTES)."', '".htmlspecialchars($datos[4], ENT_QUOTES)."')";
							$db->execute($sql, "none");
							} else {
								$error[] = "<li>Optional questions require 5 columns only, ".count($datos)." found on row $counter, please review</li>";
							}
							break;
						case "open":
							if(count($datos) == 1){
							$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", {$_SESSION['user']}, '{$_POST['question_type']}', '".htmlspecialchars($datos[0], ENT_QUOTES)."')";
							$db->execute($sql, "none");
							} else {
								$error[] = "<li>Open questions require 1 columns only, ".count($datos)." found on row $counter, please review</li>";
							}
							break;
						case "multiple":
							if(count($datos) >= 3 && count($datos) <= 9){
							$sql = "INSERT INTO questions (uid, owner, question_type, question, answer, answera, answerb, answerc, falsea, falseb, falsec, falsed) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['question_type']}', '".htmlspecialchars($datos[0], ENT_QUOTES)."', '".htmlspecialchars($datos[1], ENT_QUOTES)."', '".htmlspecialchars($datos[2], ENT_QUOTES)."', '".htmlspecialchars($datos[3], ENT_QUOTES)."', '".htmlspecialchars($datos[4], ENT_QUOTES)."', '".htmlspecialchars($datos[5], ENT_QUOTES)."', '".htmlspecialchars($datos[6], ENT_QUOTES)."', '".htmlspecialchars($datos[7], ENT_QUOTES)."', '".htmlspecialchars($datos[8], ENT_QUOTES)."')";
							$db->execute($sql, "none");
							} else {
								$error[] = "<li>Multiple questions require between 3 and 9 columns only, ".count($datos)." found on row $counter, please review</li>";
							}
							break;
						case "match":
							if(count($datos) == 2){
							$sql = "INSERT INTO questions (uid, owner, question_type, question, answer) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", {$_SESSION['user']}, '{$_POST['question_type']}', '".htmlspecialchars($datos[0], ENT_QUOTES)."', '".htmlspecialchars($datos[1], ENT_QUOTES)."')";
							$db->execute($sql, "none");
							} else {
								$error[] = "<li>Match questions require 2 columns only, ".count($datos)." found on row $counter, please review</li>";
							}
							break;
						case "essays":
							if(count($datos) == 1){
							$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", {$_SESSION['user']}, '{$_POST['question_type']}', '".htmlspecialchars($datos[0], ENT_QUOTES)."')";
							$db->execute($sql, "none");
							} else {
								$error[] = "<li>Essay questions require 1 columns only, ".count($datos)." found on row $counter, please review</li>";
							}
							break;
						case "problems":
							if(count($datos) == 1){
							$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", {$_SESSION['user']}, '{$_POST['question_type']}', '".htmlspecialchars($datos[0], ENT_QUOTES)."')";
							$db->execute($sql, "none");
							} else {
								$error[] = "<li>Problem quiestions require 1 columns only, ".count($datos)." found on row $counter, please review</li>";
							}
							break;
						case "truefalse":
							if(count($datos) == 2){
							$sql = "INSERT INTO questions (uid, owner, question_type, question, answer) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", {$_SESSION['user']}, '{$_POST['question_type']}', '".htmlspecialchars($datos[0], ENT_QUOTES)."', '".htmlspecialchars($datos[1], ENT_QUOTES)."')";
							$db->execute($sql, "none");
							} else {
								$error[] = "<li>True/False questions require 2 columns only, ".count($datos)." found on row $counter, please review</li>";
							}
							break;
					}
					$counter++;
				}
			}
			break;
/* --------------------------------------------------------------------------- */
		case "optional":
			$sql = "INSERT INTO questions (uid, owner, question_type, question, answer, falsea, falseb, falsec) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'],  ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['question'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answer'], ENT_QUOTES)."', '".htmlspecialchars($_POST['false_answera'], ENT_QUOTES)."', '".htmlspecialchars($_POST['false_answerb'], ENT_QUOTES)."', '".htmlspecialchars($_POST['false_answerc'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			break;
/* --------------------------------------------------------------------------- */
		case "open":
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questiona'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questionb'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questionc'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questiond'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			break;
/* --------------------------------------------------------------------------- */
		case "multiple":
			$sql = "INSERT INTO questions (uid, owner, question_type, question, answer, answera, answerb, answerc, falsea, falseb, falsec, falsed) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['question'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answera'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answerb'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answerc'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answerd'], ENT_QUOTES)."', '".htmlspecialchars($_POST['falsea'], ENT_QUOTES)."', '".htmlspecialchars($_POST['falseb'], ENT_QUOTES)."', '".htmlspecialchars($_POST['falsec'], ENT_QUOTES)."', '".htmlspecialchars($_POST['falsed'], ENT_QUOTES)."')";
			break;
/* --------------------------------------------------------------------------- */
		case "match":
			$sql = "INSERT INTO questions (uid, owner, question_type, question, answer) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questiona'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answera'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question, answer) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questionb'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answerb'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question, answer) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questionc'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answerc'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question, answer) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questiond'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answerd'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			break;
/* --------------------------------------------------------------------------- */
		case "essays":
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questiona'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questionb'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questionc'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questiond'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			break;
/* --------------------------------------------------------------------------- */
		case "problems":
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questiona'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questionb'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questionc'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questiond'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			break;
/* --------------------------------------------------------------------------- */
		case "truefalse":
			$sql = "INSERT INTO questions (uid, owner, question_type, question, answer) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questiona'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answera'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question, answer) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questionb'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answerb'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question, answer) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questionc'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answerc'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			$sql = "INSERT INTO questions (uid, owner, question_type, question, answer) VALUES (".htmlspecialchars($_POST['uid'], ENT_QUOTES).", ".htmlspecialchars($_SESSION['user'], ENT_QUOTES).", '{$_POST['questiontype']}', '".htmlspecialchars($_POST['questiond'], ENT_QUOTES)."', '".htmlspecialchars($_POST['answerd'], ENT_QUOTES)."')";
			$db->execute($sql, "none");
			break;
/* --------------------------------------------------------------------------- */
	}
}

if(array_key_exists("action", $_GET)){
	$action = preg_replace("/[^a-zA-Z0-9\s]/", "", $_GET['action']);
	if($action == "delete" && array_key_exists("delete_id", $_GET)){
		$id = preg_replace("/[^a-zA-Z0-9\s]/", "", $_GET['delete_id']);
		$sql = "DELETE FROM course_content WHERE owner = {$_SESSION['user']} AND id = $id AND contenttype = 'exam'";
		$delete_result = $db->execute($sql, "none");
		if($delete_result == true){
			$message = "The exam has been deleted correctly";
		}
	}
	if($action == "added"){
		$message = "The Exam has been created correctly";
	}
}

$sql = "SELECT * FROM course_content WHERE owner = {$_SESSION['user']} AND contenttype = 'exam'";
$exams = $db->execute($sql, "all");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PIE EDUCATION | Test and Exam Management</title>
<link rel="stylesheet" type="text/css" href="/css/style-student.css" />
<link href="/css/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript" src="/js/index.js"></script>
<script language="JavaScript" src="/js/ts_picker.js"></script>
<script language="Javascript1.2">
<!--
setTimeout('location.href="/logout.php?expire=1"',600000);
// -->
</script>
<script>
$(document).ready(function() {
	$("#accordion").accordion({ autoHeight: false });
	$("#accordion-grade").accordion({ autoHeight: false });
	$("#accordion-questions-type").accordion({ autoHeight: false });
	$("#tabs").tabs({ fx: { opacity: 'toggle' } });
});

$(function() {
$( "#dialog-form" ).dialog({
	autoOpen: false,
	height: 500,
	width: 980,
	modal: true,
	closeOnEscape: true,
	buttons: {
		"Save The Grades": function() {
			//Aqui va el contenido del boton de Create an account
			alert("Boton presionado");
		},
		Cancel: function() {
			$( this ).dialog( "close" );
		}
	},
	close: function() {
		//Algo que hacer cuando se cierra la ventana
	}
});

$( ".openform" ).click(function() {
		alert(this.name);
		$( "#dialog-form" ).dialog( "open" );
	});
});
</script>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-35230372-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#000000"><table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350" height="30">&nbsp;</td>
        <td align="right" valign="bottom"><a href="class.php" class="top-menu" style="color:#999">MY CLASS</a> <a href="schedule.php" class="top-menu" style="color:#999">CALENDAR</a> <a href="homework.php" class="top-menu" style="color:#999">HOMEWORK</a> <a href="test.php" class="top-menu" style="color:#999">EXAMS</a> <a href="grades.php" class="top-menu" style="color:#999">GRADES</a> <a href="tools.php" class="top-menu" style="color:#999">TOOLS</a> <a href="/logout.php" class="top-menu" style="color:#999">SIGN OUT</a></td>
      </tr>
	  <tr>
        <td>&nbsp;</td>
        <td align="right" valign="bottom"><a href="/profile/" class="login-menu" style="color:#FFF"><?php echo $_SESSION['name'].' '.$_SESSION['lname']; ?></a> <a href="/common/redirect.php" class="login-menu" style="color:#FFF">My Documents</a> <a href="/network/" class="login-menu" style="color:#FFF">My Wall</a> <a href="/common/settings.php" class="login-menu" style="color:#FFF">Settings</a></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="30" style="background-image:url(/images/top-bg-student.png); background-repeat:repeat-x">&nbsp;</td>
  </tr>
  <tr>
    <td height="550" valign="top">
    <?php 
    if(isset($error) && count($error) > 0){
	echo '<table width="980" border="0" align="center" cellpadding="4" cellspacing="4">
      <tr>
        <td style="font-family:Arial, Helvetica, sans-serif; font-size:10px; font-style:italic; color:#F00"><ul>';
          foreach($error as $error_display){
			  echo $error_display;
		  }
        echo '</ul></td>
      </tr>
    </table>';
	}
	?>
    <!-- Tabs Start -->
    <table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
      <?php
      if(isset($message)){
      echo '<tr>
				<td height="30" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:18px; font-weight:bold; color:#F00"">The exam has been deleted correctly</td>
		  </tr>';
      }
      ?>
      <tr>
        <td><div id="tabs">
    <ul style="background-color:#999">
        <li><a href="#fragment-1"><span>My Exams</span></a></li>
        <li><a href="#fragment-2"><span>Create New Exam</span></a></li>
        <li><a href="#fragment-3"><span>Grade Exams</span></a></li>
        <li><a href="#fragment-4"><span>Review Exams Results</span></a></li>
        <li><a href="#fragment-5"><span>Add Questions</span></a></li>
        <li><a href="#fragment-6"><span>Exams Statistics</span></a></li>
    </ul>
    <div id="fragment-1">
        <table width="100%" border="0" align="center" cellpadding="4" cellspacing="2">
          <?php
		  if($exams == false){
          echo '<tr>
              <td height="50" colspan="6" align="center"><div style="font-family:Arial, Helvetica, sans-serif; font-size:18px; font-weight:bold; color:#F00">No exam was found</div><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#999">To create a new exam click on the <strong>"Create New Exam"</strong> tab above</span></td>
          </tr>';
		  } else {
			  echo '<tr>
				<td width="25%" bgcolor="#CCCCCC" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold">Title</td>
				<td width="19%" bgcolor="#CCCCCC" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold">Question Quantity</td>
				<td width="14%" bgcolor="#CCCCCC" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold">Type</td>
				<td width="14%" bgcolor="#CCCCCC" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold">Timer</td>
				<td width="14%" bgcolor="#CCCCCC" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold">Automatic Grade</td>
				<td width="14%" bgcolor="#CCCCCC" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold">Delete</td>
			  </tr>';
			  foreach($exams as $exam){
				  echo '<tr>
					<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px;"><a href="test-edit.php?id='.$exam['id'].'" title="Click to Edit or View the Exam details" style="color:#00F;">'.$exam['title'].'</a></td>
					<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;">'.$exam['question_quantity'].'</td>
					<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;">'.$exam['question_type'].'</td>
					<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;">'.$exam['question_timer'].'</td>
					<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;">'.$exam['automatic_score'].'</td>
					<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;"><a href="test.php?action=delete&delete_id='.$exam['id'].'" onclick="return confirm(\'Are you sure you want to delete this Exam?\')" style="color:#00F;">Delete</a></td>
				  </tr>';
			  }
		  }
          ?>
        </table>
    </div>
    <div id="fragment-2">
        <?php
			$sql = "SELECT name, link FROM course WHERE creator = '{$_SESSION['user']}'";
			$course = $db->execute($sql, "all");
			$counter = 0;
			$options = "";
			if($course != false){
				foreach($course as $row){
					$sql = "SELECT id, title FROM course_modules WHERE link = '{$row['link']}'";
					$course_modules = $db->execute($sql, "all");
					if($course_modules == false){
						continue;
					} else {
						$options .= '<OPTGROUP LABEL="'.$row['name'].'">';
						foreach($course_modules as $modules){
							$options .= '<option value="'.$modules['id'].'">'.$modules['title'].'</option>';
							$counter++;
						}
						$options .= '</OPTGROUP>';
					}
				}
			}
		?>
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td><form id="setupexam" name="setupexam" method="post" action="class-create-review.php" onsubmit="return setupexamValidation();">
          <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td height="50" style="color:#999; font-size:14px">To setup a new test please provide the information below. You will be asked to provide questions/answer for the exam or to choose them from our knowledge database
                <input name="contenttype" type="hidden" id="contenttype" value="exam" />
                <input name="returnto" type="hidden" id="returnto" value="true" /></td>
              </tr>
            <tr>
              <td>
                <table width="100%" border="0" align="center" cellpadding="4" cellspacing="4">
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"><strong>Exam Title <span style="color:#F00">*</span></strong></td>
                    <td colspan="3"><input name="title" type="text" class="form-course" id="title" tabindex="17" /></td>
                  </tr>
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"><strong>Create Exam For <span style="color:#F00">*</span></strong></td>
                    <td colspan="3"><select name="uid" class="form-course" id="uid" tabindex="2">
                	<option value="0" selected="selected">Please Select a Module</option>
                  <?php
				  	echo $options;
                  ?>
                </select></td>
                  </tr>
                  <tr>
                    <td width="130" align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"><strong>Questions Setup <span style="color:#F00">*</span></strong></td>
                    <td><select name="questions_type" class="form-course-small" id="questions_type" tabindex="18">
                      <option value="0" selected="selected">Questions Type</option>
                      <option value="optional">Optional Choice</option>
                      <option value="open">Open Answer</option>
                      <option value="multiple">Multiple Choice</option>
                      <option value="matching">Match Question/Answer</option>
                      <option value="essays">Essays</option>
                      <option value="problems">Solve Problems Question</option>
                      <option value="truefalse">True / False</option>
                    </select></td>
                    <td><select name="questions_quantity" class="form-course-small" id="questions_quantity" tabindex="20">
                      <option value="0" selected="selected">Questions Quantity</option>
                      <option value="1">1</option>
                      <option value="2">2</option>
                      <option value="3">3</option>
                      <option value="4">4</option>
                      <option value="5">5</option>
                      <option value="6">6</option>
                      <option value="7">7</option>
                      <option value="8">8</option>
                      <option value="9">9</option>
                      <option value="10">10</option>
                      <option value="11">11</option>
                      <option value="12">12</option>
                      <option value="13">13</option>
                      <option value="14">14</option>
                      <option value="15">15</option>
                      <option value="16">16</option>
                      <option value="17">17</option>
                      <option value="18">18</option>
                      <option value="19">19</option>
                      <option value="20">20</option>
                      <option value="25">25</option>
                      <option value="30">30</option>
                      <option value="35">35</option>
                      <option value="40">40</option>
                      <option value="45">45</option>
                      <option value="50">50</option>
                      <option value="55">55</option>
                      <option value="60">60</option>
                      <option value="65">65</option>
                      <option value="70">70</option>
                      <option value="75">75</option>
                      <option value="80">80</option>
                      <option value="85">85</option>
                      <option value="90">90</option>
                      <option value="95">95</option>
                      <option value="100">100</option>
                    </select></td>
                    <td width="130" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:10px"><a href="#" onclick="javascript:add_questions();">Add This Configuration</a></td>
                    </tr>
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif">&nbsp;</td>
                    <td colspan="3" style="font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#999"><input name="question_type" type="hidden" id="question_type" value="0" />
                      <input name="question_quantity" type="hidden" id="question_quantity" value="0" />
                      <span id="questions_status">Select your question type and question quantity from the dropdowns above and then click &quot;Add this configuration&quot; link to apply that settings. The selected settings will appear in this part, you can add up to 7 different questions type.</span></td>
                  </tr>
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"><strong>Question Source <span style="color:#F00">*</span></strong></td>
                    <td colspan="3"><select name="question_source" class="form-course" id="question_source">
                      <option value="private" selected="selected">Use My Own Questions: I'll enter the questions to the system</option>
                      <option value="public">Use Public Questions: I'll use questions already created by another users</option>
                    </select></td>
                  </tr>
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"><strong>Display Type <span style="color:#F00">*</span></strong></td>
                    <td colspan="3"><select name="question_display2" class="form-course" id="question_display2" tabindex="19">
                      <option value="0" selected="selected">All the questions at the Same Time</option>
                      <option value="1">1 Question at a Time</option>
                      <option value="2">2 Questions at a Time</option>
                      <option value="3">3 Questions at a Time</option>
                      <option value="4">4 Questions at a Time</option>
                      <option value="5">5 Questions at a Time</option>
                      <option value="6">6 Questions at a Time</option>
                      <option value="7">7 Questions at a Time</option>
                      <option value="8">8 Questions at a Time</option>
                      <option value="9">9 Questions at a Time</option>
                      <option value="10">10 Questions at a Time</option>
                      <option value="11">11 Questions at a Time</option>
                      <option value="12">12 Questions at a Time</option>
                      <option value="13">13 Questions at a Time</option>
                      <option value="14">14 Questions at a Time</option>
                      <option value="15">15 Questions at a Time</option>
                      <option value="16">16 Questions at a Time</option>
                      <option value="17">17 Questions at a Time</option>
                      <option value="18">18 Questions at a Time</option>
                      <option value="19">19 Questions at a Time</option>
                      <option value="20">20 Questions at a Time</option>
                      <option value="25">25 Questions at a Time</option>
                      <option value="30">30 Questions at a Time</option>
                      <option value="35">35 Questions at a Time</option>
                      <option value="40">40 Questions at a Time</option>
                      <option value="45">45 Questions at a Time</option>
                      <option value="50">50 Questions at a Time</option>
                      <option value="55">55 Questions at a Time</option>
                      <option value="60">60 Questions at a Time</option>
                      <option value="65">65 Questions at a Time</option>
                      <option value="70">70 Questions at a Time</option>
                      <option value="75">75 Questions at a Time</option>
                      <option value="80">80 Questions at a Time</option>
                      <option value="85">85 Questions at a Time</option>
                      <option value="90">90 Questions at a Time</option>
                      <option value="95">95 Questions at a Time</option>
                      <option value="100">100 Questions at a Time</option>
                      </select></td>
                  </tr>
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"><strong>Automatic Score <span style="color:#F00">*</span></strong></td>
                    <td colspan="3"><select name="automatic_score" class="form-course" id="automatic_score" tabindex="21">
                      <option value="Yes" selected="selected">Yes</option>
                      <option value="No">No</option>
                      </select></td>
                  </tr>
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"><strong>Set Timer <span style="color:#F00">*</span></strong></td>
                    <td colspan="3"><select name="question_timer" class="form-course" id="question_timer" tabindex="22">
                      <option value="0" selected="selected">No Timer</option>
                      <option value="5">5 Seconds Per Question</option>
                      <option value="10">10 Seconds Per Question</option>
                      <option value="15">15 Seconds Per Question</option>
                      <option value="20">20 Seconds Per Question</option>
                      <option value="25">25 Seconds Per Question</option>
                      <option value="30">30 Seconds Per Question</option>
                      <option value="60">1 Minute Per Question</option>
                      <option value="120">2 Minutes Per Question</option>
                      <option value="180">3 minutes Per Question</option>
                      <option value="300">5 Minutes Per Question</option>
                      <option value="600">10 Minutes Per Question</option>
                      <option value="900">15 Minutes Per Question</option>
                      <option value="1200">20 Minutes Per Question</option>
                      </select></td>
                  </tr>
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"><strong>Start Date</strong></td>
                    <td colspan="3"><input name="start_date" type="text" class="form-course" id="start_date" tabindex="23" /> <a href="javascript:show_calendar('document.setupexam.start_date', document.setupexam.start_date.value);"> <img src="/images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp" /></a></td>
                  </tr>
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"><strong>End Date</strong></td>
                    <td colspan="3"><input name="end_date" type="text" class="form-course" id="end_date" tabindex="24" />  <a href="javascript:show_calendar('document.setupexam.end_date', document.setupexam.end_date.value);"> <img src="/images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp" /></a></td>
                    </tr>
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif"><strong>Show Calculator</strong></td>
                    <td colspan="3"><select name="calculator" class="form-course" id="calculator" tabindex="17">
                      <option value="Yes">Yes</option>
                      <option value="No" selected="selected">No</option>
                      </select></td>
                  </tr>
                  <tr>
                    <td align="right" style="font-size:14px; font-family:Arial, Helvetica, sans-serif">&nbsp;</td>
                    <td colspan="3" style="color:#F00; font-family:Arial, Helvetica, sans-serif"><em>all the fields marked with * are required fields</em></td>
                  </tr>
                  <tr>
                    <td colspan="4" align="center"><input name="send13" type="submit" class="submit-center" id="send13" value="Create The Test" tabindex="25" /></td>
                  </tr>
                  </table>
                </td>
              </tr>
            </table>
            </form></td>
          </tr>
          </table>
    </div>
    <div id="fragment-3">
		<?php
		if($exams == false){
    	echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><div style="font-family:Arial, Helvetica, sans-serif; font-size:18px; font-weight:bold; color:#F00">No exam was found</div><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#999">To create a new exam click on the <strong>"Create New Exam"</strong> tab above</span></td>
          </tr>
        </table>';
		} else {
		echo '<!-- Start accordion -->
        <div id="accordion">';
		
           foreach($exams as $row){
				echo '<h3><a href="#">'.$row['title'].'</a></h3>
				<div>';
			   $sql = "SELECT * FROM exams WHERE exam_id = {$row['id']} AND grade_provided = 'No'";
			   $user_exam = $db->execute($sql, "all");
			   if($user_exam == false){
				   echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
						  <tr>
							<td align="center" height="100"><div style="font-family:Arial, Helvetica, sans-serif; font-size:16px; font-weight:bold;">No Student Has Finish The Exam Yet</div><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#999">Please come back and check the results later</span></td>
						  </tr>
						</table>';
			   } else {
			   echo '<table width="100%" border="0" cellspacing="4" cellpadding="4">
					  <tr>
						<td width="30%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Full Name</strong></td>
						<td width="18%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Date</strong></td>
						<td width="18%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Total Questions</strong></td>
						<td width="14%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Finished In</strong></td>
						<td width="20%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Grade Exam</strong></td>
					  </tr>';
					  $counter = 0;
					  foreach($user_exam as $user_records){
						if($counter % 2){
							$color = ' bgcolor="#ffffff"';
						} else {
							$color = "";
						}
						  echo '<tr'.$color.'>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$user_records['fname'].' '.$user_records['lname'].'</td>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$user_records['applied'].'</td>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$user_records['total_questions'].'</td>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$user_records['time_taken'].' Seconds</td>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px"><div id="grade'.$user_records['id'].'"><a href="#" name="'.$user_records['id'].'" class="openform" style="color:#00F">Grade This Exam</a></div></td>
						  </tr>';
						$counter++;
					  }
					echo '</table>';
			   }
			   echo '</div>';
		   }
		}
		?>
		</div>
        <!-- End accordion -->
    </div>
    <div id="fragment-4">
        <?php
		if($exams == false){
        echo '<table width="100%" border="0" cellspacing="4" cellpadding="4">
          <tr>
            <td align="center"><div style="font-family:Arial, Helvetica, sans-serif; font-size:18px; font-weight:bold; color:#F00">No exam to review was found</div><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#999">To create a new exam click on the <strong>"Create New Exam"</strong> tab above</span></td>
          </tr>
        </table>';
		} else {
			echo '<div id="accordion-grade">';
			foreach($exams as $exam_review){
				$sql = "SELECT * FROM exams WHERE exam_id = {$exam_review['id']} AND grade_provided = 'Yes'";
				$exam_review_results = $db->execute($sql, "all");
				echo '<h3><a href="#">'.$exam_review['title'].'</a></h3>
					<div>';
					if($exam_review_results == false){
				   echo '<table width="100%" border="0" align="center" cellpadding="4" cellspacing="4">
					  <tr>
						<td align="center"><div style="font-family:Arial, Helvetica, sans-serif; font-size:18px; font-weight:bold; color:#F00">No Answered Exams Has Been Found</div><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#999">We were unable to find any answered exam at this time, come back later</span></td>
					  </tr>
				   </table>';
					} else {
					echo '<table width="100%" border="0" align="center" cellpadding="4" cellspacing="4">
					  <tr>
						<td width="28%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Full Name</strong></td>
						<td width="13%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Correct</strong></td>
						<td width="13%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Incorrect</strong></td>
						<td width="18%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Total Questions</strong></td>
						<td width="13%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Total Time</strong></td>
						<td width="14%" align="center" bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Final Grade</strong></td>
					  </tr>';
					  $counter = 0;
					  foreach($exam_review_results as $review_data){
						if($counter % 2){
							$color = ' bgcolor="#ffffff"';
						} else {
							$color = "";
						}
						  echo '<tr'.$color.'>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px"><a href="#" style="color:#00F">'.$review_data['fname'].' '.$review_data['lname'].'</a></td>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$review_data['total_good'].'</td>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$review_data['total_bad'].'</td>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$review_data['total_questions'].'</td>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$review_data['time_taken'].' Seconds</td>
							<td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$review_data['total_result'].'</td>
						  </tr>';
						  $counter++;
					  }
					echo '</table>';
					}
				echo '</div>';
			}
		echo '</div>';	
		}
	?>
    </div>
    <div id="fragment-5">
        <!-- Accordion Start -->
        <div id="accordion-questions-type">
            <h3><a href="#">Create Question Type: <strong> From File</strong></a></h3>
            <div>
                <form action="test.php" method="post" enctype="multipart/form-data" name="questionsupload" id="questionsupload" onsubmit="return questionsUploadValidation();">
                	<table width="100%" border="0" align="center" cellpadding="4" cellspacing="4">
                      <tr>
                        <td align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Create  Into  <span style="color:#F00">*</span></strong></td>
                        <td><select name="uid" class="form-course" id="uid" tabindex="2">
                          <option value="0" selected="selected">Please Select a Module</option>
                          <?php
				  	echo $options;
                  ?>
                        </select></td>
                      </tr>
                      <tr>
                        <td width="150" align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Questions Type <span style="color:#F00">*</span></strong></td>
                        <td><select name="question_type" class="form-course" id="question_type" tabindex="18">
                          <option value="optional" selected="selected">Optional Choice</option>
                          <option value="open">Open Answer</option>
                          <option value="multiple">Multiple Choice</option>
                          <option value="match">Match Question/Answer</option>
                          <option value="essays">Essays</option>
                          <option value="problems">Solve Problems Question</option>
                          <option value="truefalse">True / False</option>
                        </select></td>
                      </tr>
                      <tr>
                        <td align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Choose a  File <span style="color:#F00">*</span></strong></td>
                        <td><input name="csv_file" type="file" class="form-course" id="csv_file" tabindex="2" style="width:700px" /></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td style="font-family:Arial, Helvetica, sans-serif; font-size:9px;">File Format Examples: <a href="#" style="font-family:Arial, Helvetica, sans-serif; font-size:9px;">Optional Choice</a> <a href="#" style="font-family:Arial, Helvetica, sans-serif; font-size:9px;">Open Answer</a> <a href="#" style="font-family:Arial, Helvetica, sans-serif; font-size:9px;">Multiple Choice</a> <a href="#" style="font-family:Arial, Helvetica, sans-serif; font-size:9px;">Match Question</a> <a href="#" style="font-family:Arial, Helvetica, sans-serif; font-size:9px;">Essays</a> <a href="#" style="font-family:Arial, Helvetica, sans-serif; font-size:9px;">Solve Problems</a> <a href="#" style="font-family:Arial, Helvetica, sans-serif; font-size:9px;">True / False</a></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#F00"><em>All the fields marked with * are required fields. The file should be a CSV (comma separate value) file, save an Microsoft Excel file as CSV. Each column should be a value. Beware of the use of commas inside the file, this could cause unexpected problems</em></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td style="font-size:11px"><input name="questiontype" type="hidden" id="questiontype" value="file" />                          <input name="button2" type="submit" class="submit" id="button2" value="Upload File And Create Questions" /></td>
                      </tr>
                    </table>
                </form>
            </div>
            <h3><a href="#">Create Question Type: <strong>From Database</strong></a></h3>
            <div>
            <form action="test.php" method="post" name="selectquestions" id="selectquestions">
                <table width="100%" border="0" align="center" cellpadding="4" cellspacing="4">
                  <tr>
                    <td align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Create  Into <span style="color:#F00">*</span></strong></td>
                    <td><select name="uid" class="form-course" id="uid" tabindex="2">
                      <option value="0" selected="selected">Please Select a Module</option>
                      <?php
				  	echo $options;
                  ?>
                    </select></td>
                  </tr>
                  <tr>
                    <td width="150">&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                </table>
                </form>
            </div>
            <h3><a href="#">Create Question Type: <strong>Optional Choice</strong></a></h3>
            <div>
                <form action="test.php" method="post" name="optional" id="optional" onsubmit="return optionalQuestionsValidation();">
                	<table width="100%" border="0" align="center" cellpadding="4" cellspacing="4">
                      <tr>
                        <td width="150" align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Create  Into</strong></td>
                        <td><select name="uid" class="form-course" id="uid" tabindex="2">
                	<option value="0" selected="selected">Please Select a Module</option>
                  <?php
				  	echo $options;
                  ?>
                </select></td>
                      </tr>
                      <tr>
                        <td align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Question</strong></td>
                        <td><input name="question" type="text" class="form-course" id="question" tabindex="" /></td>
                      </tr>
                      <tr>
                        <td align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Answer</strong></td>
                        <td><input name="answer" type="text" class="form-course" id="answer" tabindex="3" /></td>
                      </tr>
                      <tr>
                        <td align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>False Answer</strong></td>
                        <td><input name="false_answera" type="text" class="form-course" id="false_answera" tabindex="4" /></td>
                      </tr>
                      <tr>
                        <td align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>False Answer</strong></td>
                        <td><input name="false_answerb" type="text" class="form-course" id="false_answerb" tabindex="4" /></td>
                      </tr>
                      <tr>
                        <td align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>False Answer</strong></td>
                        <td><input name="false_answerc" type="text" class="form-course" id="false_answerc" tabindex="4" /></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td style="color:#00F; font-family:Arial, Helvetica, sans-serif; font-size:9px"><em>All the fields in this form are required</em></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td style="font-size:11px"><input name="questiontype" type="hidden" id="questiontype" value="optional" />                          <input name="button" type="submit" class="submit" id="button" value="Add Question" /></td>
                      </tr>
                    </table>
                </form>
            </div>
            <h3><a href="#">Create Question Type: <strong>Open Answer</strong></a></h3>
            <div>
                <form action="test.php" method="post" id="openquestion" name="openquestion" onsubmit="return openQuestionsValidation();">
                	<table width="100%" border="0" cellspacing="4" cellpadding="4">
                      <tr>
                        <td width="150" align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Create  Into <span style="color:#F00">*</span></strong></span></td>
                        <td><select name="uid" class="form-course" id="uid" tabindex="2">
                          <option value="0" selected="selected">Please Select a Module</option>
                          <?php
				  	echo $options;
                  ?>
                        </select></td>
                      </tr>
                      <tr>
                        <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Question</strong></span></td>
                        <td><input name="questiona" type="text" class="form-course" id="questiona" tabindex="4" /></td>
                      </tr>
                      <tr>
                        <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Question </strong></span><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></td>
                        <td><input name="questionb" type="text" class="form-course" id="questionb" tabindex="4" /></td>
                      </tr>
                      <tr>
                        <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Question </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></span></td>
                        <td><input name="questionc" type="text" class="form-course" id="questionc" tabindex="4" /></td>
                      </tr>
                      <tr>
                        <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Question </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></span></td>
                        <td><input name="questiond" type="text" class="form-course" id="questiond" tabindex="4" /></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F"><em>You can provided from 1 to 5 questions at a time, at least one question is needed. </em></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td><span style="font-size:11px">
                          <input name="questiontype" type="hidden" id="questiontype" value="open" />
                        </span>                          <input name="button3" type="submit" class="submit" id="button3" value="Add Questions" /></td>
                      </tr>
                    </table>
                </form>
            </div>
            <h3><a href="#">Create Question Type: <strong>Multiple Choice</strong></a></h3>
            <div>
              <form id="multiple" name="multiple" method="post" action="test.php" onsubmit="return multipleQuestionsValidation();">
                <table width="100%" border="0" align="center" cellpadding="4" cellspacing="4">
                  <tr>
                    <td width="150" align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Create  Into</strong></span></td>
                    <td><select name="uid" class="form-course" id="uid" tabindex="2">
                      <option value="0" selected="selected">Please Select a Module</option>
                      <?php
				  	echo $options;
                  ?>
                    </select></td>
                  </tr>
                  <tr>
                    <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Question</strong></span></td>
                    <td><input name="question" type="text" class="form-course" id="question" tabindex="1" /></td>
                  </tr>
                  <tr>
                    <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Answer</strong></span></td>
                    <td><input name="answera" type="text" class="form-course" id="answera" tabindex="1" /></td>
                  </tr>
                  <tr>
                    <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Answer </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></span></td>
                    <td><input name="answerb" type="text" class="form-course" id="answerb" tabindex="1" /></td>
                  </tr>
                  <tr>
                    <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Answer </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></span></td>
                    <td><input name="answerc" type="text" class="form-course" id="answerc" tabindex="1" /></td>
                  </tr>
                  <tr>
                    <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Answer </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></span></td>
                    <td><input name="answerd" type="text" class="form-course" id="answerd" tabindex="1" /></td>
                  </tr>
                  <tr>
                    <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>False Answer</strong></span></td>
                    <td><input name="falsea" type="text" class="form-course" id="falsea" tabindex="1" /></td>
                  </tr>
                  <tr>
                    <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>False Answer </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></span></td>
                    <td><input name="falseb" type="text" class="form-course" id="falseb" tabindex="1" /></td>
                  </tr>
                  <tr>
                    <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>False Answer </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></span></td>
                    <td><input name="falsec" type="text" class="form-course" id="falsec" tabindex="1" /></td>
                  </tr>
                  <tr>
                    <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>False Answer </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></span></td>
                    <td><input name="falsed" type="text" class="form-course" id="falsed" tabindex="1" /></td>
                  </tr>
                  <tr>
                    <td align="right">&nbsp;</td>
                    <td><span style="font-size:11px">
                      <input name="questiontype" type="hidden" id="questiontype" value="multiple" />
                      </span>                      <input name="button4" type="submit" class="submit" id="button4" value="Save Question" /></td>
                  </tr>
                  </table>
              </form>
            </div>
            <h3><a href="#">Create Question Type: <strong>Match Questions</strong></a></h3>
            <div>
                <form action="test.php" method="post" name="matchquestion" id="matchquestion" onsubmit="return matchQuestionsValidation();"><table width="100%" border="0" cellspacing="4" cellpadding="4">
  <tr>
    <td width="150" align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Create  Into</strong></span></td>
    <td><select name="uid" class="form-course" id="uid" tabindex="2">
      <option value="0" selected="selected">Please Select a Module</option>
      <?php
				  	echo $options;
                  ?>
    </select></td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" align="center"><strong>Question</strong></td>
        <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" align="center" width="50%"><strong>Answer</strong></td>
        </tr>
      <tr>
        <td align="center"><input name="questiona" type="text" class="form-course-short" id="questiona" /></td>
        <td align="center"><input name="answera" type="text" class="form-course-short" id="questiona2" /></td>
        </tr>
      <tr>
        <td align="center"><input name="questionb" type="text" class="form-course-short" id="questionb" /></td>
        <td align="center"><input name="answerb" type="text" class="form-course-short" id="answerb" /></td>
        </tr>
      <tr>
        <td align="center"><input name="questionc" type="text" class="form-course-short" id="questionc" /></td>
        <td align="center"><input name="answerc" type="text" class="form-course-short" id="answerc" /></td>
        </tr>
      <tr>
        <td align="center"><input name="questiond" type="text" class="form-course-short" id="questiond" /></td>
        <td align="center"><input name="answerd" type="text" class="form-course-short" id="answerd" /></td>
        </tr>
      <tr>
        <td align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#00F">At least one question is needed, all the other three questions are optionals</td>
        <td align="center">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="center"><input name="button5" type="submit" class="submit-center" id="button5" value="Save Questions" />
          <span style="font-size:11px">
          <input name="questiontype" type="hidden" id="questiontype" value="match" />
          </span></td>
        </tr>
      </table></td>
  </tr>
  </table>
</form>
            </div>
            <h3><a href="#">Create Question Type: <strong>Essays</strong></a></h3>
            <div>
                <form action="test.php" method="post" name="essays" id="essays" onsubmit="return essaysQuestionsValidation();"><table width="100%" border="0" cellspacing="4" cellpadding="4">
  <tr>
    <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Create  Into</strong></span></td>
    <td><select name="uid" class="form-course" id="uid" tabindex="2">
      <option value="0" selected="selected">Please Select a Module</option>
      <?php
				  	echo $options;
                  ?>
    </select></td>
  </tr>
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" width="150" align="right"><strong>Question</strong></td>
    <td><input name="questiona" type="text" class="form-course" id="questiona" /></td>
  </tr>
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" align="right"><strong>Question </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></td>
    <td><input name="questionb" type="text" class="form-course" id="questiona3" /></td>
  </tr>
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" align="right"><strong>Question </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></td>
    <td><input name="questionc" type="text" class="form-course" id="questionc" /></td>
  </tr>
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" align="right"><strong>Question </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></td>
    <td><input name="questiond" type="text" class="form-course" id="questiond" /></td>
  </tr>
  <tr>
    <td align="right" >&nbsp;</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#00F">At least one question is needed, all the other are optionals</td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td><span style="font-size:11px">
      <input name="questiontype" type="hidden" id="questiontype" value="essays" />
    </span>      <input name="button6" type="submit" class="submit" id="button6" value="Save Questions" /></td>
  </tr>
                </table>
</form>
            </div>
            <h3><a href="#">Create Question Type: <strong>Solve Problems</strong></a></h3>
            <div>
               <form action="test.php" method="post" name="problems" id="problems" onsubmit="return problemsQuestionsValidation();">
                 <table width="100%" border="0" cellspacing="4" cellpadding="4">
                   <tr>
                     <td align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Create  Into</strong></span></td>
                     <td><select name="uid" class="form-course" id="uid" tabindex="2">
                       <option value="0" selected="selected">Please Select a Module</option>
                       <?php
				  	echo $options;
                  ?>
                     </select></td>
                   </tr>
                   <tr>
                     <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" width="150" align="right"><strong>Problem</strong></td>
                     <td><input name="questiona" type="text" class="form-course" id="questiona" /></td>
                   </tr>
                   <tr>
                     <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" align="right"><strong>Problem </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></td>
                     <td><input name="questionb" type="text" class="form-course" id="questiona5" /></td>
                   </tr>
                   <tr>
                     <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" align="right"><strong>Problem </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></td>
                     <td><input name="questionc" type="text" class="form-course" id="questionc" /></td>
                   </tr>
                   <tr>
                     <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" align="right"><strong>Problem </strong><span style="font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#00F">(optional)</span></td>
                     <td><input name="questiond" type="text" class="form-course" id="questiond" /></td>
                   </tr>
                   <tr>
                     <td align="right" >&nbsp;</td>
                     <td style="font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#00F">At least one question is needed, all the other are optionals</td>
                   </tr>
                   <tr>
                     <td align="right">&nbsp;</td>
                     <td><span style="font-size:11px">
                       <input name="questiontype" type="hidden" id="questiontype" value="problems" />
                     </span>                       <input name="button7" type="submit" class="submit" id="button7" value="Save Questions" /></td>
                   </tr>
                 </table>
               </form>
            </div>
            <h3><a href="#">Create Question Type: <strong>True or False</strong></a></h3>
            <div>
                <form action="test.php" method="post" name="truefalse" id="truefalse" onsubmit="return truefalseQuestionsValidation();">
                  <table width="100%" border="0" cellspacing="4" cellpadding="4">
                    <tr>
                      <td width="150" align="right"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px"><strong>Create  Into <span style="color:#F00">*</span></strong></span></td>
                      <td><select name="uid" class="form-course" id="uid" tabindex="2">
                        <option value="0" selected="selected">Please Select a Module</option>
                        <?php
				  	echo $options;
                  ?>
                      </select></td>
                    </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="4" cellpadding="4">
                        <tr>
                          <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" align="center"><strong>Question</strong></td>
                          <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px" align="center" width="50%"><strong>Answer</strong></td>
                        </tr>
                        <tr>
                          <td align="center"><input name="questiona" type="text" class="form-course-short" id="questiona4" /></td>
                          <td align="center"><select name="answera" class="form-course-short" id="answera">
                            <option value="true" selected="selected">true</option>
                            <option value="false">false</option>
                          </select></td>
                        </tr>
                        <tr>
                          <td align="center"><input name="questionb" type="text" class="form-course-short" id="questionb" /></td>
                          <td align="center"><select name="answerb" class="form-course-short" id="answerb">
                            <option value="true" selected="selected">true</option>
                            <option value="false">false</option>
                          </select></td>
                        </tr>
                        <tr>
                          <td align="center"><input name="questionc" type="text" class="form-course-short" id="questionc" /></td>
                          <td align="center"><select name="answerc" class="form-course-short" id="answerc">
                            <option value="true" selected="selected">true</option>
                            <option value="false">false</option>
                          </select></td>
                        </tr>
                        <tr>
                          <td align="center"><input name="questiond" type="text" class="form-course-short" id="questiond" /></td>
                          <td align="center"><select name="answerd" class="form-course-short" id="answerd">
                            <option value="true" selected="selected">true</option>
                            <option value="false">false</option>
                          </select></td>
                        </tr>
                        <tr>
                          <td align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#00F">At least one question is needed, all the other three are optionals</td>
                          <td align="center">&nbsp;</td>
                        </tr>
                        <tr>
                          <td colspan="2" align="center"><input name="button8" type="submit" class="submit-center" id="button8" value="Save Questions" />
                            <span style="font-size:11px">
                            <input name="questiontype" type="hidden" id="questiontype" value="truefalse" />
                            </span></td>
                        </tr>
                      </table></td>
                    </tr>
                  </table>
                </form>
            </div>
        </div>
		<!-- Accordion End -->
    </div>
    <div id="fragment-6">
    	Chart data here
    </div>
</div></td>
      </tr>
	</table>
	<!-- Tabs End -->
</td>
  </tr>
  <tr>
    <td height="30" align="center" style=" background-image:url(../images/bottom-bg-student.png); background-repeat:repeat-x;">&nbsp;</td>
  </tr>
  <tr>
    <td height="50" align="center" bgcolor="#000000" style="color:#fff; font-family:Arial, Helvetica, sans-serif">PIE.EDU All Rights Reserved 2012<br />
      <a href="/common/privacy.php" class="bottom-menu" style="color:#999">Privacy Policy</a> | <a href="/common/terms.php" class="bottom-menu"  style="color:#999">Terms of Use</a> | <a href="/help/main.php" class="bottom-menu" style="color:#999">Help Center</a> | <a href="/common/jobs.php" class="bottom-menu" style="color:#999">Jobs</a></td>
  </tr>
    </table>
<div id="dialog-form" title="Review The Exam">
    
</div>
</body>
</html>